home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / stik_dev / include / drivers.h next >
C/C++ Source or Header  |  1996-09-22  |  7KB  |  166 lines

  1. /*
  2.  *      drivers.h           (c) Steve Adam   1995
  3.  *                              steve@netinfo.com.au
  4.  *                   Support by Dan Ackerman 1996
  5.  *                              ackerman.29@postbox.acs.ohio-state.edu
  6.  *
  7.  *      Data types etc. for access to STiK TCP/IP drivers.
  8.  */
  9.  
  10. #ifndef STIK_DRIVERS_H
  11. #define STIK_DRIVERS_H
  12.  
  13.  
  14. /*--------------------------------------------------------------------------*/
  15.  
  16. /*
  17.  * Data types used throughout STiK
  18.  */
  19. typedef          char  int8;
  20. typedef unsigned char uint8;
  21. typedef          int   int16;
  22. typedef unsigned int  uint16;
  23. typedef          long  int32;
  24. typedef unsigned long uint32;
  25.  
  26. #ifndef TRUE
  27. #define TRUE    1
  28. #endif
  29. #ifndef FALSE
  30. #define FALSE   0
  31. #endif
  32.  
  33. #define MAX_STATES    12         /* Was 16, must be > 2 and < 256           */
  34. #define MAX_HDR      128         /* XXX 4bsd-ism : should really be 128     */
  35.  
  36. /*
  37.  * The minimum IP header
  38.  */
  39. typedef struct ip_header {
  40.     unsigned ver : 4;         /*  Version                                   */
  41.     unsigned ihl : 4;         /*  Internet Header Length                    */
  42.     unsigned tos : 8;         /*  Type of Service                           */
  43.     int16  len;               /*  Total length, 16 bits                     */
  44.     uint16  id;               /*  Identification, 16 bits                   */
  45.     int16  ofst;              /*  Fragment offset, 16 bits, includes Flags  */
  46.     uint8   ttl;              /*  Time to live, 8 bits                      */
  47.     uint8   ptcl;             /*  Protocol, 8 bits                          */
  48.     uint16  sum;              /*  Header checksum, 16 bits                  */
  49.     uint32  s_ip;             /*  Source Address, 32 bits                   */
  50.     uint32  d_ip;             /*  Destination Address, 32 bits              */
  51.  /* char optlen;                  Length of options field, in bytes         */
  52.  /* char options[IP_MAXOPT];      Options field                             */
  53. } IP_HDR;
  54.  
  55.  
  56. /*--------------------------------------------------------------------------*/
  57.  
  58. /*
  59.  * STIK global configuration structure
  60.  */
  61. typedef struct config {
  62.     uint32  client_ip;          /* IP address of client (local) machine     */
  63.     uint32  provider;           /* IP address of provider, or 0L            */
  64.     uint16  ttl;                /* Default TTL for normal packets           */
  65.     uint16  ping_ttl;           /* Default TTL for 'ping'ing                */
  66.     uint16  mtu;                /* Default MTU (Maximum Transmission Unit)  */
  67.     uint16  mss;                /* Default MSS (Maximum Segment Size)       */
  68.     uint16  df_bufsize;         /* Size of defragmentation buffer to use    */
  69.     uint16  rcv_window;         /* TCP receive window                       */
  70.     uint16  def_rtt;            /* Initial RTT time in ms                   */
  71.     int16   time_wait_time;     /* How long to wait in 'TIME_WAIT' state    */
  72.     int16   unreach_resp;       /* Response to unreachable local ports      */
  73.     int32   cn_time;            /* Time connection was made                 */
  74.     int16   cd_valid;           /* Is Modem CD a valid signal ??            */
  75.     int16   line_protocol;      /* What type of connection is this          */
  76.     void    (*old_vec)(void);   /* Old vector address                       */
  77.     struct  slip *slp;          /* Slip structure for happiness             */
  78.     char    *cv[101];           /* Space for extra config variables         */
  79.     int16   reports;            /* Problem reports printed to screen ??     */
  80.     int16   max_num_ports;      /* Maximum number of ports supported        */
  81.     uint32  received_data;      /* Counter for data being received          */
  82.     uint32  sent_data;          /* Counter for data being sent              */
  83. } CONFIG;
  84.  
  85.  
  86. /*--------------------------------------------------------------------------*/
  87.  
  88. /*
  89.  * Driver access structure / functions
  90.  */
  91. #define MAGIC   "STiKmagic"
  92. #define CJTAG   "STiK"
  93.  
  94. typedef struct drv_header {                 /* Header part of TPL structure */
  95.     char *module;
  96.     char *author;
  97.     char *version;
  98. } DRV_HDR;
  99.  
  100. typedef struct drv_list {
  101.     char      magic[10];                    /* Magic string, def'd as MAGIC */
  102.     DRV_HDR * cdecl (*get_dftab) (char *);  /* Get Driver Function Table    */
  103.     int16     cdecl (*ETM_exec) (char *);   /* Execute a STiK module        */
  104.     CONFIG    *cfg;
  105. } DRV_LIST;
  106.  
  107. extern DRV_LIST *drivers;
  108.  
  109. #define get_dftab(x)    (*drivers->get_dftab)(x)
  110. #define ETM_exec(x)     (*drivers->ETM_exec)(x)
  111. #define stik_cfg        (drivers->cfg)
  112.  
  113.  
  114. /*--------------------------------------------------------------------------*/
  115.  
  116. /*
  117.  * "state" data for each active tcp conversation on the wire.
  118.  */
  119. struct cstate {
  120.      struct cstate   *cs_next;       /* Next mru cstate (transmit only)     */
  121.      unsigned short  cs_hlen;        /* Size of header (receive only)       */
  122.      unsigned char   cs_id;          /* Con. no. associated with this state */
  123.      unsigned char   cs_filler;
  124.      union {
  125.           char             csu_hdr[MAX_HDR];
  126.           struct ip_header csu_ip;   /* Header from most recent packet      */
  127.      } slcs_u;
  128. };
  129.  
  130. #define cs_ip   slcs_u.csu_ip
  131. #define cs_hdr  slcs_u.csu_hdr
  132.  
  133. /*
  134.  * Serial line state - we need one per line 
  135.  */
  136. typedef struct slcompress {
  137.      struct cstate  *last_cs;                /* Most recently used tstate   */
  138.      uint8          last_recv;               /* Last received connection id */
  139.      uint8          last_xmit;               /* Last sent connection id     */
  140.      uint8          flags;
  141.      struct cstate  *tstate[MAX_STATES];     /* Transmit connection states  */
  142.      struct cstate  *rstate[MAX_STATES];     /* Receive connection states   */
  143. };
  144.  
  145. typedef struct slip {
  146.      void   *bdev;      /* Backlink to interface, cast this to (DEV_LIST *) */
  147.      short  flags;                    /* Misc flags, meaning see below      */
  148.      struct slcompress *comp;         /* States for VJ compression          */
  149. };
  150.  
  151. /*
  152.  * Bit masks for 'flags' entry in 'struct slip'
  153.  */
  154. #define SLF_ESC        0x01      /* Next char is escaped                    */
  155. #define SLF_DROP       0x02      /* Drop this packet                        */
  156. #define SLF_LINKED     0x04      /* Interface is linked to device           */
  157. #define SLF_COMPRESS   0x08      /* Turn on VJ compression                  */
  158. #define SLF_AUTOCOMP   0x10      /* Enable comp. on TCP_UNCOMP. frame       */
  159. #define SLF_COMPCID    0x20      /* Enable CID compression                  */
  160. #define SLF_USRMASK    (SLF_COMPRESS|SLF_AUTOCOMP|SLF_COMPCID)
  161.  
  162.  
  163. /*--------------------------------------------------------------------------*/
  164.  
  165. #endif /* STIK_DRIVERS_H */
  166.